#include <bits/stdc++.h>
//#include "head.h"
using namespace std;
using ll = long long;

void solve()
{
    int L, n;
    cin >> L >> n;
    vector<int> pos(L + 2, 0);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        pos[x] = 1;
    }
    int mid = L / 2;
    int mintime = 0;
    for (int i = mid; i >= 1; i--)
    {
        if (pos[i] == 1)
        {
            mintime = max(mintime, i);
            break;
        }
    }
    for (int i = mid + 1; i < L + 1; i++)
    {
        if (pos[i] == 1)
        {
            mintime = max(mintime, L + 1 - i);
            break;
        }
    }
    int maxtime = L + 1 - (find(pos.begin(), pos.end(), 1) - pos.begin());
    for (int i = L; i >= 0; i--)
    {
        if (pos[i] == 1)
        {
            maxtime = max(maxtime, i);
        }
    }
    if (maxtime == -1) maxtime = 0;
    cout << mintime << ' ' << maxtime;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}